php remove object from array by property

155

php remove object from array by property -

$new_array = [];
foreach ($myarray as $key => $value) {
    if ($value->catid == 29) {
        $new_array[] = $value;
        unset($myarray[$key]);        
    }
}

Comments

Submit
0 Comments